package com.group3.controller.teacherController;


import com.group3.domain.AttendanceResult;
import com.group3.domain.PunchRecord;
import com.group3.pojo.receive.AttendanceReceive;
import com.group3.pojo.receive.RecordReceive;
import com.group3.pojo.result.LeaveDetailResult;
import com.group3.service.ALeaveService;
import com.group3.service.TeacherAttendanceService;
import com.group3.utils.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * @ClassName TeacherLeaveController - 考勤管理
 * @Author jt-sinlio,MHH,PX
 * @Time 2021/6/4 9:25
 **/

@Api(tags = "教师接口")
@RestController
@RequestMapping("/teacher/attendance")
public class TeacherAttendanceController {
    @Resource
    TeacherAttendanceService teacherAttendanceService;
    @Resource
    private ALeaveService aLeaveService;
//-------------------------项目考勤记录------------------------

    // 查询项目考勤记录
    @ApiOperation(value = "查询项目考勤记录")
    @GetMapping(value = "")
    public Result<List<AttendanceResult>> selectAttendance(
             AttendanceReceive attendanceReceive, HttpServletRequest request) {
        String token = request.getHeader("token");//获取token

        return teacherAttendanceService.selectAttendance(attendanceReceive,token);
    }

    // 查询单条请假记录的详情
    @ApiOperation(value = "查询单条请假记录的详情")
    @GetMapping(value = "/resource")
    public Result<LeaveDetailResult> showAttendance(Integer leaveId) {
        return aLeaveService.showLeave(leaveId);
    }


//-------------------------门禁打卡记录------------------------

    @ApiOperation(value = "查询门禁打卡记录")
    @GetMapping(value = "/record")
    public Result<List<PunchRecord>> selectRecord(RecordReceive recordReceive) {
        return teacherAttendanceService.selectRecord(recordReceive);
    }
}
